//
//  AddressController.m
//  HaoHaiSpell
//
//  Created by 郭健 on 16/6/17.
//  Copyright © 2016年 海城. All rights reserved.
//

#import "AddressController.h"

#import "AddressView.h"
#import "ShippingAddressController.h"

@interface AddressController ()

@property (nonatomic,strong)AddressView *addressView;
@property (nonatomic,strong)UIToolbar *toolBar;

@end

@implementation AddressController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.addressView = [[AddressView alloc]init];
    self.areaTF.inputView = self.addressView;
    self.areaTF.inputAccessoryView = self.toolBar;
    
   
    
}

-(UIToolbar *)toolBar{

    if (_toolBar ==nil) {
        
        self.toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 35)];
        _toolBar.barTintColor = [UIColor grayColor];
        UIBarButtonItem *item1 =[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        
        UIBarButtonItem *item2 = [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(click)];
        _toolBar.items = @[item1,item2];
        
    }
    
    return _toolBar;
    
}

-(void)click{

    if (_areaTF.isFirstResponder) {
        [_areaTF resignFirstResponder];
        
        self.areaTF.text = [NSString stringWithFormat:@"%@%@%@",self.addressView.province,self.addressView.city,self.addressView.area];
    }
}

- (IBAction)determineBtn:(UIButton *)sender {
    
//    NSLog(@"等待传值给上个界面");

     [[NSNotificationCenter defaultCenter] postNotificationName:@"name" object:nil userInfo:@{@"key":_goodsTF.text}];

    [self.navigationController popViewControllerAnimated:YES];
}









- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
